<!DOCTYPE html >
<html>
<head>
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.common.dynamic.js" ></script>
    <script src="../libraries/RGraph.common.tooltips.js" ></script>
    <script src="../libraries/RGraph.drawing.xaxis.js" ></script>
    <script src="../libraries/RGraph.drawing.yaxis.js" ></script>
    <script src="../libraries/RGraph.drawing.rect.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
    
    <title>A Bar chart made with the Drawing API objects</title>
    
    <meta name="robots" content="noindex,nofollow" />
    <meta name="description" content="A Bar chart that is made up from drawing API objects" />
    
</head>
<body>

    <h1>A Bar chart made with the Drawing API objects</h1>
    
    <p>
        This is a demo of the Drawing API objects being used to make a bar chart all by themselves (without the actual Bar chart).
    </p>

    <canvas id="cvs" width="600" height="250">[No canvas support]</canvas>
    
    <script>
        $(document).ready(function ()
        {
            var data = [100,80,60,40,20];
            var labels = ['Fred','Barney','Wilma','Betty','Dino'];
            var hmargin = 5;
            var max = 100;
    
            var xaxis = new RGraph.Drawing.XAxis({
                id: 'cvs',
                y: 225,
                options: {
                    labels: labels,
                    gutter: {
                        left: 50
                    },
                    tooltips: ['The X axis shows Flintstones characters']
                }
            }).draw()
    
            var yaxis = new RGraph.Drawing.YAxis({
                id: 'cvs',
                x: 50,
                options: {
                    max: max,
                    noendtick: {
                        bottom: true
                    },
                    scale: {
                        zerostart: false
                    },
                    noyaxis: true,
                    tooltips: ['The Y axis shows a scale of how much the characters did<br /> something - at some point']
                }
            }).draw()
        
            for (var i=0; i<data.length; ++i) {
    
                var width = ((600-50-25) / data.length) - (hmargin * 2);
                var height = (data[i] / max) * (xaxis.canvas.height - 25 - 25);
                var x = 50 + (((600-50-25) / data.length) * i) + hmargin;
                var y = 250 - 25 - height;
            
                var rect = new RGraph.Drawing.Rect({
                    id: 'cvs',
                    x: x,
                    y: y,
                    width: width,
                    height: height,
                    options: {
                        tooltips: [labels[i]],
                        highlight: {
                            stroke: 'rgba(0,0,0,0)'
                        }
                    }
                }).draw()
            }
            
            RGraph.redraw();
        });
    </script>
    
    <p>
        <b>Is it quicker than using the standard Bar chart?</b><br />
        No.
    </p>
    
    <p>
        <b>Is it easier to implement than the standard Bar chart?</b><br />
        No.
    </p>
    
    <p>
        <b>Is it easier to maintain than the standard Bar chart?</b><br />
        No.
    </p>
    
    <p>
        <b>Does it encompass all of the features of the standard Bar chart?</b><br />
        No.
    </p>
    
    <p>
        <b>So why?</b><br />
        It's just an example of three of the drawing API objects - the XAxis, the Yaxis and the Rect. If what you want is a Bar
        chart - use the RGraph Bar chart.
    </p>

    <p>
        <a href="./">&laquo; Back</a>
    </p>

</body>
</html>